import React from "react";
import PriviteRouter from "./PriviteRouter";
import { useSelector } from "react-redux";

const Login = React.lazy(() => import("../pages/login/index"));
const Home = React.lazy(() => import("../pages/home/index"));
const Search = React.lazy(() => import("../pages/search/index"));
const Airplane = React.lazy(() => import("../pages/trip/airplane/index"));
const Detail = React.lazy(() => import("../pages/trip/detail/index"));
const Order = React.lazy(() => import("../pages/order/index"));

const staticRoutes = [
  {
    path: "/login",
    element: <Login></Login>,
  },
  {
    path: "/",
    element: <Home></Home>,
  },
  {
    path: "/search",
    element: <Search></Search>,
  },
  {
    path: "/trip/airplane",
    element: <Airplane></Airplane>,
  },
  {
    path: "/trip/detail",
    element: <Detail></Detail>,
  },
  {
    path: "/order/",
    auth: true, // 需要登录
    element: <Order></Order>,
  },
];

export const routes = staticRoutes.map((v) => {
  return {
    ...v,
    element: <PriviteRouter isAuth={v.auth}>{v.element}</PriviteRouter>,
  };
});
